/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agh.air.bpel2bpmn.comparator.impl;

import org.agh.air.bpel2bpmn.comparator.AbstractComparator;
import org.agh.air.bpel2bpmn.exception.PatternNotFoundException;
import org.w3c.dom.Node;

/**
 *
 * @author paletz
 */
public class SynchronizationComparator extends AbstractComparator{

    
   /* <process>
        <flow>
          <invoke name="Task2"/>
          <invoke name="Task3"/>
        </flow>
    </process>
   */

    @Override
    public String compare(Node node) throws PatternNotFoundException {
        if(node.getNodeName().equals(SEQUENCE)) {
            if(node.hasChildNodes() && node.getChildNodes().getLength()==2){
                if(node.getChildNodes().item(0).getNodeName().equals(INVOKE) 
                        && node.getChildNodes().item(1).getNodeName().contains(FLOW))
                    return "synchronization"+ LTMP + getNameAttribute(getFirstChild(node)) + "." + getSecondChild(node).getNodeName() + RTMP;
            }
        }
            
        
        throw new PatternNotFoundException();
    }
    
}
